﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="Details.aspx.vb" Inherits="Prototype.Details" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table border="1">
<tr>
<td>
    <asp:Panel ID="Panel2" runat="server">
        <asp:Panel ID="Panel3" runat="server">
            <asp:ListView ID="ListView2" runat="server" DataSourceID="detailsDataSource">
                <AlternatingItemTemplate>
                    <span style="">Bookname:
                    <b><asp:Label ID="BooknameLabel" runat="server" Text='<%# Eval("Bookname") %>' /></b>
                    <br />
                    Author:
                    <asp:Label ID="AuthorLabel" runat="server" Text='<%# Eval("Author") %>' />
                    <br />
                    YearPublished:
                    <asp:Label ID="YearPublishedLabel" runat="server" 
                        Text='<%# Eval("YearPublished") %>' />
                    <br />
                    Series:
                    <asp:Label ID="SeriesLabel" runat="server" Text='<%# Eval("Series") %>' />
                    <br />
                    <asp:Image ID="PictureLabel" runat="server" ImageUrl='<%# Eval("Picture") %>'
                    Height="350px" Width="300px"  />
                    <br />
                    
                    <asp:Label ID="DescriptionLabel" runat="server" 
                        Text='<%# Eval("Description") %>' />
                    <br />
                    MainCharacters:
                    <asp:Label ID="MainCharactersLabel" runat="server" 
                        Text='<%# Eval("MainCharacters") %>' />
                    <br />
                    
                    WikipediaPage:
                    
                        <a href="<%# Eval("WikipediaPage") %>"><%# Eval("WikipediaPage") %></a>
                        
                    <br />
                    <br />
                    </span>
                </AlternatingItemTemplate>
                <EditItemTemplate>
                    <span style="">Bookname:
                    <asp:TextBox ID="BooknameTextBox" runat="server" 
                        Text='<%# Bind("Bookname") %>' />
                    <br />
                    Author:
                    <asp:TextBox ID="AuthorTextBox" runat="server" Text='<%# Bind("Author") %>' />
                    <br />
                    YearPublished:
                    <asp:TextBox ID="YearPublishedTextBox" runat="server" 
                        Text='<%# Bind("YearPublished") %>' />
                    <br />
                    Series:
                    <asp:TextBox ID="SeriesTextBox" runat="server" Text='<%# Bind("Series") %>' />
                    <br />
                    
                    <asp:TextBox ID="PictureTextBox" runat="server" Text='<%# Bind("Picture") %>' 
                    Height="350px" Width="300px" />
                    <br />
                    
                    <asp:TextBox ID="DescriptionTextBox" runat="server" 
                        Text='<%# Bind("Description") %>' />
                    <br />
                    MainCharacters:
                    <asp:TextBox ID="MainCharactersTextBox" runat="server" 
                        Text='<%# Bind("MainCharacters") %>' />
                    <br />
                    
                    WikipediaPage:
                    <a href="<%# Eval("WikipediaPage") %>">'<%# Eval("WikipediaPage") %></a><br /><asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                        Text="Update" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Cancel" />
                    <br />
                    <br />
                    </span>
                </EditItemTemplate>
                <EmptyDataTemplate>
                    <span>No data was returned.</span>
                </EmptyDataTemplate>
                <InsertItemTemplate>
                    <span style="">Bookname:
                    <asp:TextBox ID="BooknameTextBox" runat="server" 
                        Text='<%# Bind("Bookname") %>' />
                    <br />
                    Author:
                    <asp:TextBox ID="AuthorTextBox" runat="server" Text='<%# Bind("Author") %>' />
                    <br />
                    YearPublished:
                    <asp:TextBox ID="YearPublishedTextBox" runat="server" 
                        Text='<%# Bind("YearPublished") %>' />
                    <br />
                    Series:
                    <asp:TextBox ID="SeriesTextBox" runat="server" Text='<%# Bind("Series") %>' />
                    <br />
                    <asp:TextBox ID="PictureTextBox" runat="server" Text='<%# Bind("Picture") %>' 
                    Height="350px" Width="300px" />
                    <br />
                    
                   <asp:TextBox ID="DescriptionTextBox" runat="server" 
                        Text='<%# Bind("Description") %>' />
                    <br />
                    MainCharacters:
                    <asp:TextBox ID="MainCharactersTextBox" runat="server" 
                        Text='<%# Bind("MainCharacters") %>' />
                    <br />
                    
                    WikipediaPage:
                    <a href="<%# Eval("WikipediaPage") %>"><%# Eval("WikipediaPage") %></a><br /><asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                        Text="Insert" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Clear" />
                    <br />
                    <br />
                    </span>
                </InsertItemTemplate>
                <ItemTemplate>
                    <span style="">Bookname:
                    <asp:Label ID="BooknameLabel" runat="server" Text='<%# Eval("Bookname") %>' />
                    <br />
                    Author:
                    <asp:Label ID="AuthorLabel" runat="server" Text='<%# Eval("Author") %>' />
                    <br />
                    YearPublished:
                    <asp:Label ID="YearPublishedLabel" runat="server" 
                        Text='<%# Eval("YearPublished") %>' />
                    <br />
                    Series:
                    <asp:Label ID="SeriesLabel" runat="server" Text='<%# Eval("Series") %>' />
                    <br />
                    
                    <asp:Image ID="PictureLabel" runat="server" ImageUrl='<%# Eval("Picture") %>' 
                    Height="350px" Width="300px" />
                    <br />
                    
                    <asp:Label ID="DescriptionLabel" runat="server" 
                        Text='<%# Eval("Description") %>' />
                    <br />
                    MainCharacters:
                    <asp:Label ID="MainCharactersLabel" runat="server" 
                        Text='<%# Eval("MainCharacters") %>' />
                    <br />
                    
                    WikipediaPage:
                    <a href="<%# Eval("WikipediaPage") %>"><%# Eval("WikipediaPage") %></a><br /><br /></span>
                </ItemTemplate>
                <LayoutTemplate>
                    <div ID="itemPlaceholderContainer" runat="server" style="">
                        <span runat="server" id="itemPlaceholder" />
                    </div>
                    <div style="">
                    </div>
                </LayoutTemplate>
                <SelectedItemTemplate>
                    <span style="">Bookname:
                    <asp:Label ID="BooknameLabel" runat="server" Text='<%# Eval("Bookname") %>' />
                    <br />
                    Author:
                    <asp:Label ID="AuthorLabel" runat="server" Text='<%# Eval("Author") %>' />
                    <br />
                    YearPublished:
                    <asp:Label ID="YearPublishedLabel" runat="server" 
                        Text='<%# Eval("YearPublished") %>' />
                    <br />
                    Series:
                    <asp:Label ID="SeriesLabel" runat="server" Text='<%# Eval("Series") %>' />
                    <br />
                    
                    <asp:Image ID="PictureLabel" runat="server" ImageUrl='<%# Eval("Picture") %>'
                    Height="350px" Width="300px"  />
                    <br />
                    
                    <asp:Label ID="DescriptionLabel" runat="server" 
                        Text='<%# Eval("Description") %>' />
                    <br />
                    MainCharacters:
                    <asp:Label ID="MainCharactersLabel" runat="server" 
                        Text='<%# Eval("MainCharacters") %>' />
                    <br />
                    <br />
                    WikipediaPage:
                    <a href="<%# Eval("WikipediaPage") %>"><%# Eval("WikipediaPage") %></a>
                    <br />
                    <br />
                    </span>
                </SelectedItemTemplate>
            </asp:ListView>
            <asp:SqlDataSource ID="detailsDataSource" runat="server" 
                ConnectionString="<%$ ConnectionStrings:booksConn %>" 
                ProviderName="<%$ ConnectionStrings:booksConn.ProviderName %>" 
                SelectCommand="SELECT [Bookname], [Author], [YearPublished], [Series], [Picture], [Description], [MainCharacters],  [WikipediaPage] FROM [books] WHERE ([ID] = ?)">
                <SelectParameters>
                    <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
                </SelectParameters>
            </asp:SqlDataSource>
            <br />
        </asp:Panel>
    </asp:Panel>
<br />
    </td>
    <td>
    <table>
    <tr>
    <td>
            <asp:Panel ID="stats" runat="server">
                <asp:ListView ID="ListView3" runat="server" DataSourceID="SqltagView" 
                    GroupItemCount="3" >
                    <AlternatingItemTemplate>
                        <td runat="server" style="background-color: #FFF8DC;">
                             <asp:Label ID="TagLabel" runat="server" Text='<%# Eval("Tag") %>' />
                            <br />
                        </td>
                    </AlternatingItemTemplate>
                    <EditItemTemplate>
                        <td runat="server" style="background-color: #008A8C; color: #FFFFFF;">
                            Tag:
                            <asp:TextBox ID="TagTextBox" runat="server" Text='<%# Bind("Tag") %>' />
                            <br />
                            <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                                Text="Update" />
                            <br />
                            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                                Text="Cancel" />
                            <br />
                        </td>
                    </EditItemTemplate>

                    <EmptyDataTemplate>
                        <table runat="server" 
                            style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
                            <tr>
                                <td>
                                    Not tagged yet.</td>
                            </tr>
                        </table>
                    </EmptyDataTemplate>
                    <EmptyItemTemplate>
                        <td runat="server" />
                    </EmptyItemTemplate>
                    <GroupTemplate>
                        <tr ID="itemPlaceholderContainer" runat="server">
                            <td ID="itemPlaceholder" runat="server">
                            </td>
                        </tr>
                    </GroupTemplate>
                    <InsertItemTemplate>
                        <td runat="server" style="">
                            
                            <asp:TextBox ID="TagTextBox" runat="server" Text='<%# Bind("Tag") %>' />
                            <br />
                            <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                                Text="Insert" />
                            <br />
                            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                                Text="Clear" />
                            <br />
                        </td>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <td runat="server" style="background-color: #DCDCDC; color: #000000;">
                             <asp:Label ID="TagLabel" runat="server" Text='<%# Eval("Tag") %>' />
                            <br />
                        </td>
                    </ItemTemplate>
                    <LayoutTemplate>
                        <table runat="server">
                            <tr runat="server">
                                <td runat="server">
                                    <table ID="groupPlaceholderContainer" runat="server" border="1" 
                                        style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                                        <tr ID="groupPlaceholder" runat="server">
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr runat="server">
                                <td runat="server" 
                                    
                                    style="text-align: center;background-color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
                                </td>
                            </tr>
                        </table>
                    </LayoutTemplate>
                    <SelectedItemTemplate>
                        <td runat="server" 
                            style="background-color: #008A8C; font-weight: bold;color: #FFFFFF;">
                            
                            <asp:Label ID="TagLabel" runat="server" Text='<%# Eval("Tag") %>' />
                            <br />
                        </td>
                    </SelectedItemTemplate>
                </asp:ListView>
                <asp:SqlDataSource ID="SqltagView" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:booksConn %>" 
                    ProviderName="<%$ ConnectionStrings:booksConn.ProviderName %>" 
                    SelectCommand="SELECT Tag FROM BookTag WHERE (ID IN (SELECT BookTagFkId FROM BookTagJunction WHERE (BookFkId = ?)))">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="?" QueryStringField="ID" />
                    </SelectParameters>
                </asp:SqlDataSource>
            Average ratings is 
            <asp:TextBox ID="Tb_AvgRating" runat="server"></asp:TextBox>
                <br />
                <asp:TextBox ID="Tb_numViews" runat="server"></asp:TextBox>
                Views<br />
                <asp:TextBox ID="Tb_NumLikings" runat="server"></asp:TextBox>
                Likes<br />
            <asp:TextBox ID="Tb_NumComments" runat="server"></asp:TextBox>Comments<br />
                       
            </asp:Panel>
         </td>
        </tr>
    <tr>
    <td>
        <asp:SqlDataSource ID="tagDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:booksConn %>" 
            ProviderName="<%$ ConnectionStrings:booksConn.ProviderName %>" 
            SelectCommand="SELECT [ID], [Tag] FROM [BookTag] WHERE ([Tag] &lt;&gt; ?)">
            <SelectParameters>
                <asp:Parameter DefaultValue=" " Name="Tag" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:Panel ID="Panel1" runat="server">
        <div style="background-color:Silver">
            <br />
            <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
            </asp:ToolkitScriptManager>
            <asp:ToggleButtonExtender ID="ToggleEx" runat="server"
            TargetControlID="CheckBox1" 
            ImageWidth="19" 
            ImageHeight="19"
            CheckedImageAlternateText="Check"
            UncheckedImageAlternateText="UnCheck"
            UncheckedImageUrl="~/Pictures/General/unlike.jpeg" 
            CheckedImageUrl="~/Pictures/General/like.jpeg" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:CheckBox ID="CheckBox1" runat="server" Text="Like" Font-Size="Medium" 
                AutoPostBack="True" />
        <br />
        <br />
        <br />
            <asp:Rating  BorderWidth="1" BorderStyle="Solid"
            width="200" 
            Height="40" 
            ID="Rating1"  
            CurrentRating="2" 
            runat="server" 
            StarCssClass="ratingStar" 
            WaitingStarCssClass="savedRatingStar" 
            EmptyStarCssClass="emptyRatingStar" 
            filledStarCssClass="filledRatingStar"
            MaxRating="5" AutoPostBack="True" 
            >
            </asp:Rating>
            
            <br />
            
            <br />
            <asp:CheckBoxList ID="CheckBoxList1" runat="server" 
            DataSourceID="tagDataSource" DataTextField="Tag" DataValueField="ID" 
            RepeatDirection="Horizontal">
            </asp:CheckBoxList>
            <br />
            <br />
            Add new tags here and separate tags by commas:
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <br />
            <br />
            <br />
            <asp:Button ID="Btn_tag" runat="server" Text="Submit Tag" />
            <br />
            <br />
            
            <br />
            </div>
        </asp:Panel>
        People who liked this book, Also Liked
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                DataSourceID="ViewdAlsoDataSource">
                <Columns>
                    <asp:HyperLinkField DataNavigateUrlFields="ID" 
                        DataNavigateUrlFormatString="Details.aspx?ID={0}" DataTextField="Bookname" 
                        Text="BookName" />
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="ViewdAlsoDataSource" runat="server" 
                ConnectionString="<%$ ConnectionStrings:booksConn %>" 
                ProviderName="<%$ ConnectionStrings:booksConn.ProviderName %>" 
                SelectCommand="SELECT TOP 5 Bookname,ID FROM books WHERE (ID IN (SELECT DISTINCT BookFkId FROM BookLikes WHERE (Traveller IN (SELECT Traveller FROM BookLikes BookLikes_1 WHERE (BookFkId = ?)))))">
                <SelectParameters>
                    <asp:QueryStringParameter Name="?" QueryStringField="ID" />
                </SelectParameters>
            </asp:SqlDataSource>
            <br />
        <br />
        <br />
        <br />
        </td>
        </tr>
        </table>
     </td>
    </tr>    
      </table>
    <%# Eval("WikipediaPage") %>

   
        <br />
        Add Your Comment<br />
        <br />
        <asp:TextBox ID="TB_CommentTitle" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:TextBox ID="TB_Comment" runat="server" Height="64px" TextMode="MultiLine" 
            Width="351px"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="Btn_SubmitComment" runat="server" Text="Submit" />
        <br />
        <br />      
        <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource2">
        <ItemTemplate>
        <div style="background-color:White">
        <strong>Name</strong>
                <asp:Label ID="UserNameLabel" runat="server" Text='<%# Eval("UserFkName") %>' />
                <br />

                <strong>Title</strong>
                <asp:Label ID="Label1" runat="server" Text='<%# Eval("Title") %>' />
                <br />

                <strong>Comments</strong>
                <asp:Label ID="Label2" runat="server" Text='<%# Eval("UserComments") %>' />
                <br />

                <strong>Date</strong>
                <asp:Label ID="Label3" runat="server" Text='<%# Eval("Commented_Date") %>' />
                <br />
                <br />
             </div>   
        </ItemTemplate>
            <AlternatingItemTemplate>
            <div style="background-color:Silver">
                <strong>Name</strong>
                <asp:Label ID="UserNameLabel" runat="server" Text='<%# Eval("UserFkName") %>' />
                <br />

                <strong>Title</strong>
                <asp:Label ID="Label1" runat="server" Text='<%# Eval("Title") %>' />
                <br />

                <strong>Comments</strong>
                <asp:Label ID="Label2" runat="server" Text='<%# Eval("UserComments") %>' />
                <br />

                <strong>Date</strong>
                <asp:Label ID="Label3" runat="server" Text='<%# Eval("Commented_Date") %>' />
                <br />
                <br />
                <br />
                </div>
            </AlternatingItemTemplate>
            <EmptyDataTemplate>
                        <span>No data was returned.</span>
            </EmptyDataTemplate>
                    <LayoutTemplate>
                        <div ID="itemPlaceholderContainer" runat="server" 
                            style="font-family: Verdana, Arial, Helvetica, sans-serif;">
                            <span runat="server" id="itemPlaceholder" />
                        </div>
                         <div style="text-align: center;background-color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
                            <asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="10">
                            
                                <Fields>
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                        ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                    <asp:NumericPagerField />
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                        ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                </Fields>
                            </asp:DataPager>
                        </div>
                    </LayoutTemplate>
        </asp:ListView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:booksConn %>" 
            ProviderName="<%$ ConnectionStrings:booksConn.ProviderName %>" 
            SelectCommand="SELECT [UserFkName], [Title], [UserComments], [Commented Date] AS Commented_Date FROM [BookComments] WHERE ([BookFkId] = ?)">
            <SelectParameters>
                <asp:QueryStringParameter Name="BookFkId" QueryStringField="ID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
        <br />
        <br />
    
</asp:Content>
